package com.example.cafe.work.controller;


import com.example.cafe.work.dto.Result;
import com.example.cafe.work.model.Coffee;
import com.example.cafe.work.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hua
 * @since 2024-09-16
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    //添加订单,redis中的用户id，传回的list，
    @PostMapping("add")
    public Result createOrder(@RequestBody List<Coffee> coffee, @RequestParam("Authorization") String userId){
        return orderService.createOrder(coffee,userId);
    }
    //用户的查看订单，加入状态筛选，userid筛选,分页
    @GetMapping("/getUserAll")
    public Result queryOrder(@RequestParam("state")String state,
                             @RequestParam("userId")String userId,
                             @RequestParam("page")int page,
                             @RequestParam("size")int size){
        return orderService.queryOrder(state,userId,page,size);
    }
    //支付，拿到未支付的订单的list，带userId，


    //退单

}

